home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 3 / Cream of the Crop 3.iso / clipper / ks94an.zip / __ENCRYP.HDR < prev    next >
Text File  |  1994-04-25  |  3KB  |  87 lines

  1. /******************************************************************************
  2.                  The Klipper Library, for CA-Clipper 5.x
  3.         Copyright (c), 1994, Wallace Information Systems Engineering
  4.  
  5. FUNCTION:
  6.  
  7. _Encrypt( cEncStr, cKey ) --> cEncryptStr
  8.  
  9. PARAMETERS:
  10.  
  11. cEncStr : String to be encrypted.
  12. cKey    : Character String. Code to be used as encrypt key (optional)
  13.  
  14. SHORT:
  15.  
  16. Encrypt a string.
  17.  
  18. DESCRIPTION:
  19.  
  20. _Encrypt() employs a typical XOR encryption algorythm.
  21.  
  22. NOTE:
  23.  
  24.  
  25.  
  26. EXAMPLE:
  27.  
  28. t = _Encrypt('ABCDEFG')          // t = bit-soup
  29. t = _Encrypt(t)                  // t = ABCDEFG
  30.  
  31. -and with optional key-
  32.  
  33. t = _Encrypt('SESAME','CHEESE')  // t = bit-soup simmered
  34.                                  //     in 'CHEESE' sauce
  35.  
  36. ? _Encrypt(t)                    // still bit-soup, would you like
  37.                                  // a napkin?
  38.  
  39. ? _Encrypt(t,'CHEESE')           // t = 'SESAME'
  40.  
  41. *****************************************************************
  42.  
  43. IMPORTANT: Due to the nature of an XOR encryption, especially
  44. this implementation, if you specify a NULL string as the encryption
  45. key, essentially NOTHING will happen.  The encrypted result will be
  46. exactly the same as the data being encrypted!
  47.  
  48. _Encrypt() does NOT check to see whether you have done this! (After all,
  49. you know what you are doing, right?)
  50.  
  51. This will not endanger your data, because if you do this twice, (one
  52. to encrypt and again to decrypt, the same string will be returned both
  53. times).
  54.  
  55. You may wish to look into _Crypto(), which will give a unique encryption
  56. even if you use a NULL string.  It is also MUCH faster, as it is written
  57. in "C", not Clipper.
  58.  
  59. Not also that an embedded NULL in an otherwise non-NULL key will not
  60. cause this.  This phenomenon occurs only when the entire key is a NULL
  61. string.  Tries ta be more smarts, wid dis.  OK?
  62.  
  63. *****************************************************************
  64.  
  65. cKey is optional.  If not specified, an internal password is used by default.
  66.  
  67. Remember also that concatenated values must be evaluated separately. If
  68. you evaluate two fields like so:
  69.  
  70. _encode(user+system)
  71.  
  72.     and
  73.  
  74. _encode(user)+_encode(system)
  75.  
  76. The two methods return different values.  Why?  Because when you evaluate
  77. the two fields concatenated, the decryption key does not begin fresh with
  78. the second value but continues decrypting the entire concatenanted value
  79. until done.
  80.  
  81. Subservient functions _Encode() and _Decode() can be used interchangably
  82. with _Encrypt(), since they all do the same thing.  _Encode() and
  83. _Decode() simply pass along to _Encrypt() what was passed to them. The
  84. names Encode and Decode make things a little more easy to handle.
  85.  
  86. ******************************************************************************/
  87.